using System;
using System.Collections.Generic;
using System.Text;

namespace Zsa.Reflection.Discovery
{
    /// <summary>
    /// Base class for only attributes used to declaritivly define attributes.
    /// </summary>
    public abstract class ActivationInstanceBaseAttribute : DiscoveryAttribute
    {
        #region Fields
        /// <summary>
        /// The type name.
        /// </summary>
        private Type _Type;
        /// <summary>
        /// The instance name
        /// </summary>
        private string _InstanceName;        
        /// <summary>
        /// The activation attribute type.
        /// </summary>
        private ActivationAttributeType _AttributeType;
        /// <summary>
        /// Allow configuration.
        /// </summary>
        private bool _AllowConfig;
        #endregion Fields

        #region Constructor

        /// <summary>
        /// Initializes a new instance of the <see cref="ActivationInstanceBaseAttribute"/> class.
        /// </summary>
        /// <param name="instanceName">Name of the instance.</param>
        protected ActivationInstanceBaseAttribute(string instanceName, Type type,
            ActivationAttributeType attributeType, bool allowConfig)
        {
            if (string.IsNullOrEmpty(instanceName))
            {
                throw new ArgumentException("The instance name must be set !", "instanceName");
            }
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            _InstanceName = instanceName;
            _Type = type;
            _AttributeType = attributeType;
        }

        #endregion Constructor

        #region Properties
        /// <summary>
        /// Gets the name of the instance.
        /// </summary>
        /// <value>The name of the instance.</value>
        public string InstanceName
        {
            get
            {
                return _InstanceName;
            }
        }

        /// <summary>
        /// Gets the type of the instance.
        /// </summary>
        /// <value>The type of the instance.</value>
        public Type InstanceType
        {
            get
            {
                return _Type;
            }
        }

        /// <summary>
        /// Gets the type of the activation attribute.
        /// </summary>
        /// <value>The type of the activation attribute.</value>
        public virtual ActivationAttributeType ActivationAttributeType
        {
            get
            {
                return _AttributeType;
            }
        }

        /// <summary>
        /// Gets a value indicating whether [allow config].
        /// </summary>
        /// <value><c>true</c> if [allow config]; otherwise, <c>false</c>.</value>
        public bool AllowConfig
        {
            get
            {
                return _AllowConfig;
            }
        }
        #endregion Properties 
    }
}
